/*package com.lzq.app.web.utils;

import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLEncoder;
import java.sql.Connection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExporterParameter;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.export.JRPdfExporter;
import net.sf.jasperreports.engine.export.JRRtfExporter;
import net.sf.jasperreports.engine.export.JRXlsExporter;
import net.sf.jasperreports.engine.util.JRLoader;

@SuppressWarnings("all")
public class IReportUtility {

	*//***
	 * 
	 * @param jasperFullPath		jasper文件的全路径
	 * @param fileName				导出文件名
	 * @param list					数据集
	 * @param parameters			jasper参数
	 * @param printType				导出/打印格式(pdf,xls,word)
	 * @param response				HttpServletResponse
	 *//*
	public static void export(String jasperFullPath,String fileName, List list, Map parameters,String printType,HttpServletResponse response) {
		try {
			URL uri = new URL(jasperFullPath);
			JasperReport report = (JasperReport) JRLoader.loadObject(uri);
			export(report, fileName, list, parameters, printType, response);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
	
	*//***
	 * 导出 PDF格式的报表
	 * @param jasperFullPath		jasper文件的全路径
	 * @param fileName				导出文件名
	 * @param list					数据集
	 * @param parameters			jasper参数
	 * @param response				HttpServletResponse
	 *//*
	public static void export(String jasperFullPath,String fileName, List list, Map parameters,HttpServletResponse response) {
		export(jasperFullPath,fileName, list, parameters, "pdf", response);
	}
	
	*//***
	 * 
	 * @param report			JasperReport对象
	 * @param fileName			导出文件名
	 * @param list				数据集
	 * @param parameters		jasper参数
	 * @param printType			导出/打印格式(pdf,xls,word)
	 * @param response			HttpServletResponse
	 *//*
	public static void export(JasperReport report, String fileName, List list, Map parameters,String printType,HttpServletResponse response) {
		export(report,fileName,"attachment",list,parameters,printType, response);
	}
	
	*//***
	 * 打印PDF格式报表
	 * @param report
	 * @param fileName
	 * @param list
	 * @param parameters
	 * @param response
	 *//*
	public static void print(JasperReport report, String fileName, List list, Map parameters,HttpServletResponse response) {
		export(report,fileName,"inline",list,parameters,"pdf", response);
	}
	
	public static void print(String jasperFullPath,String fileName, List list, Map parameters,HttpServletResponse response) {
		try {
			URL uri = new URL(jasperFullPath);
			JasperReport report = (JasperReport) JRLoader.loadObject(uri);
			export(report, fileName,"inline", list, parameters,"pdf", response);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
	
	public static void print(JasperDesign design, String fileName, List list, Map parameters,HttpServletResponse response) {
		try {
			JasperReport report = JasperCompileManager.compileReport(design);
			export(report, fileName,"inline", list, parameters,"pdf",response);
		} catch (JRException e) {
			e.printStackTrace();
		}
	}
	
	*//***
	 * 
	 * @param report			JasperReport对象
	 * @param fileName			导出文件名
	 * @param type 				类型<attachment,inline>
	 * @param list				数据集
	 * @param parameters		jasper参数
	 * @param printType			导出/打印格式(pdf,xls,word)
	 * @param response			HttpServletResponse
	 *//*
	public static void export(JasperReport report, String fileName, String type, List list, Map parameters,String printType,HttpServletResponse response) {
		try {
			JRDataSource dataSource = new JRBeanCollectionDataSource(list,false);
			export(report, fileName, type, dataSource, parameters, printType, response);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
	
	*//***
	 * 
	 * @param report			JasperReport对象
	 * @param fileName			导出文件名
	 * @param type 				类型<accachemnt,inline>
	 * @param ds				数据集
	 * @param parameters		jasper参数
	 * @param printType			导出/打印格式(pdf,xls,word)
	 * @param response			HttpServletResponse
	 *//*
	public static void export(JasperReport jasper, String fileName, String type, JRDataSource ds, Map param, String printType, HttpServletResponse response) {
		
		try {
			if (param == null) {
				param = new HashMap<String, String>();
			}
//			fileName = URLEncoder.encode(fileName, "UTF-8");//尝试解决firefox保存乱码
			fileName = new String(fileName.getBytes("GBK"),"iso8859-1");  
			JasperPrint jasperPrint = JasperFillManager.fillReport(jasper,param, ds);
			OutputStream ouputStream = response.getOutputStream();
			String contentType = "pdf";			// 导出类型(pdf,xls,doc)
			if("doc".equalsIgnoreCase(printType)) {
				contentType = "msword";
			} else if("xls".equalsIgnoreCase(printType)) {
				contentType = "vnd.ms-excel";
			} 
			response.reset();
			response.setContentType("application/" + contentType);
			response.setCharacterEncoding("UTF-8");
			response.setHeader("Content-Disposition", type + "; filename="+ fileName + "." + printType);// 生成文件类型(pdf,xls,html)
			ByteArrayOutputStream baos = exportStyle(jasperPrint,  printType);// 控制打印格式
			
			byte[] bytes = baos.toByteArray(); 
			ouputStream.write(bytes, 0, bytes.length); 
	        ouputStream.flush(); 
			ouputStream.close();
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		
	}
	
	*//**
	 * 生成静态SQL的报表<SQL已经定义在JASPER中>
	 * @param jasper
	 * @param fileName
	 * @param type
	 * @param conn
	 * @param param
	 * @param printType
	 * @param response
	 *//*
	public static void export(JasperReport jasper, String fileName, String type, Connection conn, Map param, String printType, HttpServletResponse response) {
		
		try {
			if (param == null) {
				param = new HashMap<String, String>();
			}
			fileName = URLEncoder.encode(fileName, "UTF-8");
			JasperPrint jasperPrint = JasperFillManager.fillReport(jasper,param, conn);
			OutputStream ouputStream = response.getOutputStream();
			String contentType = "pdf";			// 导出类型(pdf,xls,doc)
			if("doc".equalsIgnoreCase(printType)) {
				contentType = "msword";
			} else if("xls".equalsIgnoreCase(printType)) {
				contentType = "vnd.ms-excel";
			} 
			response.reset();
			response.setContentType("application/" + contentType);
			response.setCharacterEncoding("UTF-8");
			response.setHeader("Content-Disposition", type + "; filename="+ fileName + "." + printType);// 生成文件类型(pdf,xls,html)
			ByteArrayOutputStream baos = exportStyle(jasperPrint,  printType);// 控制打印格式
			
			byte[] bytes = baos.toByteArray(); 
			ouputStream.write(bytes, 0, bytes.length); 
	        ouputStream.flush(); 
			ouputStream.close();
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		
	}
	
	public static void export(JasperDesign design, String fileName, List list, Map parameters,String printType,HttpServletResponse response) {
		try {
			JasperReport report = JasperCompileManager.compileReport(design);
			export(report, fileName, list, parameters,printType,response);
		} catch (JRException e) {
			e.printStackTrace();
		}
	}
	
	 // 获取报表输出流
	public static ByteArrayOutputStream exportStyle(JasperPrint jasperPrint, String printType) throws Exception {
		
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		if ("pdf".equalsIgnoreCase(printType)) {
			// 使用JRPdfExproter导出器导出pdf
			JRPdfExporter exporter = new JRPdfExporter();
			exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
			exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos);
			exporter.exportReport();
		} else if("xls".equalsIgnoreCase(printType)) {
			// 使用JRXlsExporter导出器导出excel
			JRXlsExporter xlsExporter = new JRXlsExporter();
			xlsExporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint);
			xlsExporter.setParameter(JRExporterParameter.OUTPUT_STREAM,baos);
			xlsExporter.exportReport();
		} else if("doc".equalsIgnoreCase(printType)){
			// 使用JRRtfExporter导出器导出word
			JRRtfExporter rtfExporter = new JRRtfExporter();
			rtfExporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint);
			rtfExporter.setParameter(JRExporterParameter.OUTPUT_STREAM,baos);
			rtfExporter.exportReport();
		}
		
		return baos;
	}

}
*/